import java.util.Scanner;

public class shuzijiamihejiemi {
    public static void main(String[] args) {
        System.out.println("输入要加密的数字");
        Scanner sc = new Scanner(System.in);
        int number = sc.nextInt();
        int number1 = jiami(number);
        System.out.println("加密后的数字为" + number1);
        System.out.println("输入要解密的数字");
        int number2 = sc.nextInt();
        int number3 = jiemi(number2);
        System.out.println("解密后的数字为" + number3);

    }

    public static int jiami(int number) {
        int tmp = number;
        int wei = 0;
        while (tmp != 0) {
            tmp = tmp / 10;
            wei++;
        }
        int[] arr1 = new int[wei];
        for (int i = arr1.length - 1; number != 0; i--) {
            arr1[i] = (number % 10) + 5;
            number = number / 10;
            arr1[i] = arr1[i] % 10;
        }
        int temp = 0;
        for (int i = 0, j = arr1.length - 1; i < j; i++, j--) {
            temp = arr1[i];
            arr1[i] = arr1[j];
            arr1[j] = temp;
        }
        int number1 = 0;
        for (int i = 0; i < arr1.length; i++) {
            number1 = number1 * 10 + arr1[i];
        }
        return number1;
    }

    public static int jiemi(int number2) {
        int tmp = number2;
        int wei = 0;
        while (tmp != 0) {
            tmp = tmp / 10;
            wei++;
        }
        int[] arr = new int[wei];
        for (int i = 0; number2 != 0; i++) {
            arr[i] = number2 % 10;
            number2 = number2 / 10;
        }
        for (int i = 0, j = arr.length - 1; i < j; i++, j--) {
            int temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
        }
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] < 5) {
                arr[i] = arr[i] + 10;
            }
        }
        for (int i = 0; i < arr.length; i++) {
            arr[i] = arr[i] - 5;
        }
        for (int i = 0, j = arr.length - 1; i < j; i++, j--) {
            int temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
        }
        int number3 = 0;
        for (int i = 0; i < arr.length; i++) {
            number3 = number3 * 10 + arr[i];
        }
        return number3;
    }
}